<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws.
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.).
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations).
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./include/modules/Blog/classes/PhpFox_ComponentMyBlogs.class.php, $Author:  $ */



/** Component for showing member blogs
 *
 * @version $Id: PhpFox_ComponentMyBlogs.class.php 46 2007-12-14 23:12:21Z phpfoxsv $
 * @package module.blog
 */
class PhpFox_Mod_Blog_ComponentMyBlogs extends BaseComponent
{
    function process()
    {
        $oSecurityService = App::getModuleService('Account', 'Security');
        /* @var $oSecurityService PhpFox_Mod_Account_ServiceSecurity */
        $oReq = &App::getRequest();

		$iUserId = $this->getParam('userId');

		if ( !$iUserId )
		{
			return '';
		}

        $sUser = $oReq->get('name');
        if (!$oSecurityService->checkAccess('blogs', '', false))
        {
            return '';
        }
        if (!$oSecurityService->checkPerm('blog', array('full', 'read_only'), false))
        {
            return '';
        }
        if (App::getSetting('profile_display_blog'))
        {
            return '';
        }

		$aItems = $this->oDatabase->getRows('SELECT j.id AS `id`,  j.title AS `title`,  j.time AS `time`'.
			' FROM `'. App::getT('journal') .'` AS j '.
			' WHERE j.user_id = "'. $iUserId .'" ORDER BY time DESC LIMIT 0,'. App::getSetting('profile_blog_total') .'');

        $this->oTpl->assign(array(
            'aItems' => $aItems,
            'sUser'  => $sUser,
        ));
        return $this->oTpl->fetch('MyBlogs.html');
    }
}
?>